//
//  THHotTableViewCell.m
//  YJB
//
//  Created by 中电大维 on 2016/12/27.
//  Copyright © 2016年 YJB. All rights reserved.
//

#import "THHotTableViewCell.h"

NSString *hotCellID = @"hotCellID";

#define CommentWidth 65
#define LookWith 65
#define TimeWidth 65

@implementation THHotTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        [self hotTest];
    }
    return self;
}

- (void)hotTest
{
    //self.iconImageView.backgroundColor = [UIColor redColor];
    self.iconImageView.image = Image(@"tuhao_home_price");
    self.userLabel.text = @"用户名显示";
    self.contentLabel.text = @"对于人民币“破七”行内人士怎么看，只显示贴子标题对于人民币“破七”行内人士怎么看，只显示贴子标题。。。";
    self.categoryLabel.text = @"谈天说地";
    self.timeLabel.text = @"1小时前";
    self.lookLabel.text = @"浏览(30)";
    self.commentLabel.text = @"评论(100)";
}

- (UIImageView *)iconImageView
{
    if (!_iconImageView) {
        _iconImageView = [[UIImageView alloc] init];
        [self addSubview:_iconImageView];
        [_iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(10);
            make.left.mas_equalTo(12);
            make.width.height.mas_equalTo(45);
        }];
    }
    return _iconImageView;
}
- (UILabel *)userLabel
{
    if (!_userLabel) {
        _userLabel = [[UILabel alloc] init];
        _userLabel.textColor = kUIColorFromRGB(0xff783c);
        // 非vip用户颜色 UIColorFromRGB(0x666666);// vip用户颜色 UIColorFromRGB(0xff783c);
        _userLabel.font = FONT(16);
        [self addSubview:_userLabel];
        [_userLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.iconImageView.mas_right).offset(10);
            make.centerY.equalTo(self.iconImageView.mas_centerY);
            make.right.mas_equalTo(-12);
            make.height.mas_equalTo(18);
        }];
    }
    return _userLabel;
}
- (UIImageView *)vipImageView
{
    if (!_vipImageView) {
        _vipImageView = [[UIImageView alloc] init];
        
    }
    return _vipImageView;
}
- (UILabel *)contentLabel
{
    if (!_contentLabel) {
        _contentLabel = [[UILabel alloc] init];
        _contentLabel.font = FONT(14);
        _contentLabel.textColor = kUIColorFromRGB(0x333333);
        [self addSubview:_contentLabel];
        
        [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.iconImageView.mas_left);
            make.top.mas_equalTo(self.iconImageView.mas_bottom).offset(10);
            make.right.mas_equalTo(-12);
            make.height.mas_equalTo(15);
        }];
    }
    return _contentLabel;
}
- (UILabel *)categoryLabel
{
    if (!_categoryLabel) {
        _categoryLabel = [[UILabel alloc] init];
        _categoryLabel.textColor = kUIColorFromRGB(0x888888);
        _categoryLabel.font = FONT(13);
        _categoryLabel.textAlignment = NSTextAlignmentCenter;
        [_categoryLabel.layer setMasksToBounds:YES];
        [_categoryLabel.layer setCornerRadius:5.0];
        [_categoryLabel.layer setBorderColor:kUIColorFromRGB(0xff783c).CGColor];
        [_categoryLabel.layer setBorderWidth:1];
        
        [self addSubview:_categoryLabel];
        CGFloat width = [NSString widthForString:@"谈天说地" fontSize:13 andHeight:15]+10;
        
        [_categoryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.contentLabel.mas_bottom).offset(10);
            make.left.equalTo(self.contentLabel.mas_left);
            make.width.mas_equalTo(width);
            make.height.mas_equalTo(22);
        }];
    }
    return _categoryLabel;
}
- (UILabel *)timeLabel
{
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc] init];
        _timeLabel.textColor = kUIColorFromRGB(0x888888);
        _timeLabel.font = FONT(13);
        [self addSubview:_timeLabel];
        [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.categoryLabel.mas_centerY);
            make.right.mas_equalTo(self.lookLabel.mas_left).offset(-10);
            make.width.mas_equalTo(TimeWidth);
            make.height.equalTo(self.commentLabel.mas_height);
        }];

    }
    return _timeLabel;
}
- (UILabel *)lookLabel
{
    if (!_lookLabel) {
        _lookLabel = [[UILabel alloc] init];
        _lookLabel.textColor = kUIColorFromRGB(0x888888);
        _lookLabel.font = FONT(13);
        [self addSubview:_lookLabel];
        [_lookLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.categoryLabel.mas_centerY);
            make.right.mas_equalTo(self.commentLabel.mas_left).offset(-10);
            make.width.mas_equalTo(LookWith);
            make.height.equalTo(self.commentLabel.mas_height);
        }];
    }
    return _lookLabel;
}
- (UILabel *)commentLabel
{
    if (!_commentLabel) {
        _commentLabel = [[UILabel alloc] init];
        _commentLabel.textColor = kUIColorFromRGB(0x888888);
        _commentLabel.font = FONT(13);
        [self addSubview:_commentLabel];
        [_commentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.categoryLabel.mas_centerY);
            make.right.mas_equalTo(-18);
            make.width.mas_equalTo(CommentWidth);
            make.height.mas_equalTo(16);
        }];
    }
    return _commentLabel;
}



- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
